package com.zxk.service.impl;

import com.sun.jna.platform.win32.WinDef;
import com.zxk.app.dto.TaskMappingDto;
import com.zxk.constant.PicConstants;
import com.zxk.service.AbstractMyTask;
import com.zxk.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 剑会降分
 *
 * @author: 舟小亢
 * @date: 2024-7-7 18:40:49
 */
public class RodeDownScoreTaskImpl extends AbstractMyTask {


    private static Logger LOG = LoggerFactory.getLogger(RodeDownScoreTaskImpl.class);

    public RodeDownScoreTaskImpl(WinDef.HWND hwnd_0, WinDef.HWND hwnd_1, WinDef.HWND hwnd_2) {
        super(hwnd_0, hwnd_1, hwnd_2);
    }

    @Override
    public boolean goHome() throws Exception {
        return true;
    }

    @Override
    public String getTaskName() throws Exception {
        return TaskMappingDto.RODEO_DOWN_SCORE;
    }

    @Override
    public boolean execute() throws Exception {
        LOG.info("【剑会降分】任务开始！");
        // 1.第一次找到快速匹配
        if (!FuzzyPicUtil.findAndClickRandom(hwnd_0, hwnd_1, PicConstants.剑会降分任务_天梯匹配, 3)) {
            LOG.error("【剑会降分】没有找到快速匹配，直接等待开始匹配提示！");
        }
        LOG.info("【剑会降分】开始匹配！");
        return true;
    }

    @Override
    public boolean checkTask() throws Exception {
        LOG.info("【剑会降分】开始循环降分！");
        int i = 1;
        while (true) {
            LOG.info("【剑会降分】当前循环第[{}]次！", i);
            // 2.找到并点击开始匹配
            if (!FuzzyPicUtil.findAndClickRandom(hwnd_0, hwnd_1, PicConstants.剑会降分任务_开始匹配, 3,0.95)) {
                ThreadUtil.sleep(5000);
            }
        }
    }
}
